using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ByHand.Model;
using ByHand.Data;
using ByHand.Services.Interfaces;
using ByHand.Data.Interfaces;
using ByHand.Services.Code;

namespace ByHand.Services.Implements
{
    public class UserService : RepositoryBase<User>, IUserService
    {
        public UserService(IDatabaseFactory DbFactory) : base(DbFactory) { }
        public User Login(string email, string password) {
            var pass =Utility.HashCode(password);
            var user = (from u in ByHandDB.Users
                        where u.Email == email && u.Password == pass
                        select u).FirstOrDefault();
            return user;
        }
        public User GetByEmail(string email) {
            return (from u in ByHandDB.Users
                    where u.Email == email
                    select u).FirstOrDefault();
        }
        public User GetByFBID(string fbID) {
            return (from u in ByHandDB.Users
                    where u.FBID == fbID
                    select u).FirstOrDefault();
        }
    }
}
